
function OrderCoreDupe (ply, Pose, Movee, Grave, MF, DF, Marinee)
	local melon = ents.Create("johnny_ordermelon");
	if (!melon:IsValid()) then return false end
	melon:SetPos (Pose);
	local tab = {
		Team = ply:GetNetworkedInt("melonteam");
		Move = Movee;
		Grav = Grave;
		MovingForce = MF;
		Damping = DF;
		Marine = Marinee;
	}
		if Movve then 
  mov = 0
  else
  mov = 1
  end 
  if Grave then 
  Gra = 0
  else
  Gra = 1
  end
  if Marinee then 
  Mar = 0
  else
  Mar = 1
  end 
	table.Merge(melon:GetTable(), tab);
		if InBaseRange(ply) then
	local cost = ((2000+MF*5+DF*100-Gra*1000+Mar*500)*server_settings.Int( "WM_toolcost", 1))
    if NRGCheck(ply, cost) then
	  melon:Spawn();
	  melon:Activate();
	  DoPropSpawnedEffect(melon);
	  return melon;
	  end
	end

end
duplicator.RegisterEntityClass("johnny_ordermelon", OrderCoreDupe, "Pos", "Move", "Grav", "MovingForce", "Damping", "Marine");

function FighterDupe (ply, Pose, Marinee, Movee, Grave, Ange)
	local melon = ents.Create("johnny_fighter");
	if (!melon:IsValid()) then return false end
	melon:SetPos(Pose);
	melon:SetAngles(Ange);
	local tab = {
		Team = ply:GetNetworkedInt("melonteam");
		Marine = Marinee;
		Move = Movee;
		Grav = Grave;
	}
	local mov = 0
	local gra = 0
	if Movve then 
  mov = 0
  else
  mov = 1
  end 
  if Grave then 
  Gra = 0
  else
  Gra = 1
  end
  if Marinee then 
  Mar = 0
  else
  Mar = 1
  end 
	table.Merge(melon:GetTable(), tab);
	if InBaseRange(ply) then
	local cost = ((1500+mov*1000-Gra*1000+500*Mar)*server_settings.Int( "WM_toolcost", 1))
    if NRGCheck(ply, cost) then
	  melon:Spawn();
	  melon:Activate();
	  DoPropSpawnedEffect(melon);
	  return melon;
	  end
	end
end
duplicator.RegisterEntityClass("johnny_fighter", FighterDupe, "Pos", "Marinee", "Move", "Grav", "Ang");

function FighterDupe (ply, Pose, Marinee, Movee, Grave, Ange)
	local melon = ents.Create("johnny_fighter");
	if (!melon:IsValid()) then return false end
	melon:SetPos(Pose);
	melon:SetAngles(Ange);
	local tab = {
		Team = ply:GetNetworkedInt("melonteam");
		Marine = Marinee;
		Move = Movee;
		Grav = Grave;
	}
	local mov = 0
	local gra = 0
	if Movve then 
  mov = 0
  else
  mov = 1
  end 
  if Grave then 
  Gra = 0
  else
  Gra = 1
  end
  if Marinee then 
  Mar = 0
  else
  Mar = 1
  end 
	table.Merge(melon:GetTable(), tab);
	if InBaseRange(ply) then
	local cost = ((1500+mov*1000-Gra*1000+500*Mar)*server_settings.Int( "WM_toolcost", 1))
    if NRGCheck(ply, cost) then
	  melon:Spawn();
	  melon:Activate();
	  DoPropSpawnedEffect(melon);
	  return melon;
	  end
	end
end
duplicator.RegisterEntityClass("johnny_fighter", FighterDupe, "Pos", "Marinee", "Move", "Grav", "Ang");

function CannonDupe (ply, Pose, Movee, Grave, Ange)
	local melon = ents.Create("johnny_cannon");
	if (!melon:IsValid()) then return false end
	melon:SetPos(Pose);
	melon:SetAngles(Ange);
	local tab = {
		Team = ply:GetNetworkedInt("melonteam");
		Move = Movee;
		Grav = Grave;
	}
	local mov = 0
	local gra = 0
	if Movve then 
  mov = 0
  else
  mov = 1
  end 
  if Grave then 
  Gra = 0
  else
  Gra = 1
  end
	table.Merge(melon:GetTable(), tab);
	if InBaseRange(ply) then
	local cost = ((4000+mov*2000-Gra*2000)*server_settings.Int( "WM_toolcost", 1))
    if NRGCheck(ply, cost) then
	  melon:Spawn();
	  melon:Activate();
	  DoPropSpawnedEffect(melon);
	  return melon;
	  end
	end
end
duplicator.RegisterEntityClass("johnny_cannon", CannonDupe, "Pos", "Move", "Grav", "Ang");

function HarvesterDupe (ply, Pose, Movee, Grave, Ange)
	local melon = ents.Create("lap_harvester");
	if (!melon:IsValid()) then return false end
	melon:SetPos(Pose);
	melon:SetAngles(Ange);
	local tab = {
		Team = ply:GetNetworkedInt("melonteam");
		Move = Movee;
		Grav = Grave;
	}
	local mov = 0
	local gra = 0
	if Movve then 
  mov = 0
  else
  mov = 1
  end 
  if Grave then 
  Gra = 0
  else
  Gra = 1
  end
	table.Merge(melon:GetTable(), tab);
	if InBaseRange(ply) then
	local cost = ((5000+mov*2000-Gra*4000)*server_settings.Int( "WM_toolcost", 1))
    if NRGCheck(ply, cost) then
	  melon:Spawn();
	  melon:Activate();
	  DoPropSpawnedEffect(melon);
	  return melon;
	  end
	end
end
duplicator.RegisterEntityClass("lap_harvester", HarvesterDupe, "Pos", "Move", "Grav", "Ang");

function LightFighterDupe (ply, Pose, Movee, Grave, Ange)
	local melon = ents.Create("johnny_lightfighter");
	if (!melon:IsValid()) then return false end
	melon:SetPos(Pose);
	melon:SetAngles(Ange);
	local tab = {
		Team = ply:GetNetworkedInt("melonteam");
		Move = Movee;
		Grav = Grave;
	}
	local mov = 0
	local gra = 0
	if Movve then 
  mov = 0
  else
  mov = 1
  end 
  if Grave then 
  Gra = 0
  else
  Gra = 1
  end
	table.Merge(melon:GetTable(), tab);
	if InBaseRange(ply) then
	local cost = ((750+mov*250-Gra*500)*server_settings.Int( "WM_toolcost", 1))
    if NRGCheck(ply, cost) then
	  melon:Spawn();
	  melon:Activate();
	  DoPropSpawnedEffect(melon);
	  return melon;
	  end
	end
end
duplicator.RegisterEntityClass("johnny_lightfighter", LightFighterDupe, "Pos", "Move", "Grav", "Ang");

function BombDupe (ply, Pose, Movee, Grave, Ange)
	local melon = ents.Create("lap_bomb");
	if (!melon:IsValid()) then return false end
	melon:SetPos(Pose);
	melon:SetAngles(Ange);
	local tab = {
		Team = ply:GetNetworkedInt("melonteam");
		Move = Movee;
		Grav = Grave;
	}
	local mov = 0
	local gra = 0
	if Movve then 
  mov = 0
  else
  mov = 1
  end 
  if Grave then 
  Gra = 0
  else
  Gra = 1
  end
	table.Merge(melon:GetTable(), tab);
	if InBaseRange(ply) then
	local cost = ((1250+mov*750-Gra*1000)*server_settings.Int( "WM_toolcost", 1))
    if NRGCheck(ply, cost) then
	  melon:Spawn();
	  melon:Activate();
	  DoPropSpawnedEffect(melon);
	  return melon;
	  end
	end
end
duplicator.RegisterEntityClass("lap_bomb", BombDupe, "Pos", "Move", "Grav", "Ang");

function SniperDupe (ply, Pose, Movee, Grave, Ange)
	local melon = ents.Create("lap_sniper");
	if (!melon:IsValid()) then return false end
	melon:SetPos(Pose);
	melon:SetAngles(Ange);
	local tab = {
		Team = ply:GetNetworkedInt("melonteam");
		Move = Movee;
		Grav = Grave;
	}
	local mov = 0
	local gra = 0
	if Movve then 
  mov = 0
  else
  mov = 1
  end 
  if Grave then 
  Gra = 0
  else
  Gra = 1
  end
	table.Merge(melon:GetTable(), tab);
	if InBaseRange(ply) then
	local cost = ((3000+mov*1000-Gra*2000)*server_settings.Int( "WM_toolcost", 1))
    if NRGCheck(ply, cost) then
	  melon:Spawn();
	  melon:Activate();
	  DoPropSpawnedEffect(melon);
	  return melon;
	  end
	end
end
duplicator.RegisterEntityClass("lap_sniper", SniperDupe, "Pos", "Move", "Grav", "Ang");

function MGDupe (ply, Pose, Movee, Grave, Ange)
	local melon = ents.Create("lap_mg");
	if (!melon:IsValid()) then return false end
	melon:SetPos(Pose);
	melon:SetAngles(Ange);
	local tab = {
		Team = ply:GetNetworkedInt("melonteam");
		Move = Movee;
		Grav = Grave;
	}
	local mov = 0
	local gra = 0
	if Movve then 
  mov = 0
  else
  mov = 1
  end 
  if Grave then 
  Gra = 0
  else
  Gra = 1
  end
	table.Merge(melon:GetTable(), tab);
	if InBaseRange(ply) then
	local cost = ((3000+mov*1000-Gra*2000)*server_settings.Int( "WM_toolcost", 1))
    if NRGCheck(ply, cost) then
	  melon:Spawn();
	  melon:Activate();
	  DoPropSpawnedEffect(melon);
	  return melon;
	  end
	end
end
duplicator.RegisterEntityClass("lap_mg", MGDupe, "Pos", "Move", "Grav", "Ang");

function PCannonDupe (ply, Pose, Movee, Grave, Ange)
	local melon = ents.Create("johnny_pcannon");
	if (!melon:IsValid()) then return false end
	melon:SetPos(Pose);
	melon:SetAngles(Ange);
	local tab = {
		Team = ply:GetNetworkedInt("melonteam");
		Move = Movee;
		Grav = Grave;
	}
	local mov = 0
	local gra = 0
	if Movve then 
  mov = 0
  else
  mov = 1
  end 
  if Grave then 
  Gra = 0
  else
  Gra = 1
  end
	table.Merge(melon:GetTable(), tab);
	if InBaseRange(ply) then
	local cost = ((6000+mov*3000-Gra*3000)*server_settings.Int( "WM_toolcost", 1))
    if NRGCheck(ply, cost) then
	  melon:Spawn();
	  melon:Activate();
	  DoPropSpawnedEffect(melon);
	  return melon;
	  end
	end
end
duplicator.RegisterEntityClass("johnny_pcannon", PCannonDupe, "Pos", "Move", "Grav", "Ang");

function MedicDupe (ply, Pose, Movee, Grave, Ange, LOLFXe)
	local melon = ents.Create("johnny_medic");
	if (!melon:IsValid()) then return false end
	melon:SetPos(Pose);
	melon:SetAngles(Ange);
	local tab = {
		Team = ply:GetNetworkedInt("melonteam");
		Move = Movee;
		Grav = Grave;
		LOLFX = LOLFXe;
	}
	local mov = 0
	local gra = 0
	local lolz = 0
	if Movve then 
  mov = 0
  else
  mov = 1
  end 
  if Grave then 
  Gra = 0
  else
  Gra = 1
  end
	table.Merge(melon:GetTable(), tab);
	if InBaseRange(ply) then
	local cost = ((4500+mov*1500-Gra*3000)*server_settings.Int( "WM_toolcost", 1))
    if NRGCheck(ply, cost) then
	  melon:Spawn();
	  melon:Activate();
	  DoPropSpawnedEffect(melon);
	  return melon;
	  end
	end
end
duplicator.RegisterEntityClass("johnny_medic", MedicDupe, "Pos", "Move", "Grav", "Ang", "LOLFX");

function LaserDupe (ply, Pose, Grave, Ange)
	local melon = ents.Create("johnny_laser_l");
	if (!melon:IsValid()) then return false end
	melon:SetPos(Pose);
	melon:SetAngles(Ange);
	local tab = {
		Team = ply:GetNetworkedInt("melonteam");
		Grav = Grave;
	}
	local gra = 0
  if Grave then 
  Gra = 0
  else
  Gra = 1
  end
	table.Merge(melon:GetTable(), tab);
	if InBaseRange(ply) then
	local cost = ((2000 + Gra*1000)*server_settings.Int( "WM_toolcost", 1))
    if NRGCheck(ply, cost) then
	  melon:Spawn();
	  melon:Activate();
	  DoPropSpawnedEffect(melon);
	  return melon;
	  end
	end
end
duplicator.RegisterEntityClass("johnny_laser_l", LaserDupe, "Pos", "Grav", "Ang");

function PCannonDupe (ply, Pose, Movee, Grave, Ange)
	local melon = ents.Create("johnny_pcannon");
	if (!melon:IsValid()) then return false end
	melon:SetPos(Pose);
	melon:SetAngles(Ange);
	local tab = {
		Team = ply:GetNetworkedInt("melonteam");
		Move = Movee;
		Grav = Grave;
	}
	local mov = 0
	local gra = 0
	if Movve then 
  mov = 0
  else
  mov = 1
  end 
  if Grave then 
  Gra = 0
  else
  Gra = 1
  end
	table.Merge(melon:GetTable(), tab);
	if InBaseRange(ply) then
	local cost = ((6000+mov*3000-Gra*3000)*server_settings.Int( "WM_toolcost", 1))
    if NRGCheck(ply, cost) then
	  melon:Spawn();
	  melon:Activate();
	  DoPropSpawnedEffect(melon);
	  return melon;
	  end
	end
end
duplicator.RegisterEntityClass("johnny_pcannon", PCannonDupe, "Pos", "Move", "Grav", "Ang");

function KaboomDupe (ply, Pose, Ange)
	local melon = ents.Create("lap_kaboom");
	if (!melon:IsValid()) then return false end
	melon:SetPos(Pose);
	melon:SetAngles(Ange);
	local tab = {
		Team = ply:GetNetworkedInt("melonteam");
	}
	table.Merge(melon:GetTable(), tab);
	if InBaseRange(ply) then
	local cost = (50000*server_settings.Int( "WM_toolcost", 1))
    if NRGCheck(ply, cost) then
	  melon:Spawn();
	  melon:Activate();
	  DoPropSpawnedEffect(melon);
	  return melon;
	  end
	end
end
duplicator.RegisterEntityClass("lap_kaboom", KaboomDupe, "Pos", "Ang");

function MicrowaveLaserDupe (ply, Pose, Ange)
	local melon = ents.Create("lap_microwavelaser");
	if (!melon:IsValid()) then return false end
	melon:SetPos(Pose);
	melon:SetAngles(Ange);
	local tab = {
		Team = ply:GetNetworkedInt("melonteam");
	}
	table.Merge(melon:GetTable(), tab);
	if InBaseRange(ply) then
	local cost = (50000*server_settings.Int( "WM_toolcost", 1))
    if NRGCheck(ply, cost) then
	  melon:Spawn();
	  melon:Activate();
	  DoPropSpawnedEffect(melon);
	  return melon;
	  end
	end
end
duplicator.RegisterEntityClass("lap_microwavelaser", MicrowaveLaserDupe, "Pos", "Ang");

function ChaosDupe (ply, Pose, Ange)
	local melon = ents.Create("lap_chaos");
	if (!melon:IsValid()) then return false end
	melon:SetPos(Pose);
	melon:SetAngles(Ange);
	local tab = {
		Team = ply:GetNetworkedInt("melonteam");
	}
	table.Merge(melon:GetTable(), tab);
	if InBaseRange(ply) then
	local cost = (50000*server_settings.Int( "WM_toolcost", 1))
    if NRGCheck(ply, cost) then
	  melon:Spawn();
	  melon:Activate();
	  DoPropSpawnedEffect(melon);
	  return melon;
	  end
	end
end
duplicator.RegisterEntityClass("lap_chaos", ChaosDupe, "Pos", "Ang");

function MindControlDupe (ply, Pose, Ange)
	local melon = ents.Create("lap_mindcontrol");
	if (!melon:IsValid()) then return false end
	melon:SetPos(Pose);
	melon:SetAngles(Ange);
	local tab = {
		Team = ply:GetNetworkedInt("melonteam");
	}
	table.Merge(melon:GetTable(), tab);
	if InBaseRange(ply) then
	local cost = (50000*server_settings.Int( "WM_toolcost", 1))
    if NRGCheck(ply, cost) then
	  melon:Spawn();
	  melon:Activate();
	  DoPropSpawnedEffect(melon);
	  return melon;
	  end
	end
end
duplicator.RegisterEntityClass("lap_mindcontrol", MindControlDupe, "Pos", "Ang");

function RegenCoreDupe (ply, Pose, Ange)
	local melon = ents.Create("lap_regencore");
	if (!melon:IsValid()) then return false end
	melon:SetPos(Pose);
	melon:SetAngles(Ange);
	local tab = {
		Team = ply:GetNetworkedInt("melonteam");
	}
	table.Merge(melon:GetTable(), tab);
	if InBaseRange(ply) then
	local cost = (50000*server_settings.Int( "WM_toolcost", 1))
    if NRGCheck(ply, cost) then
	  melon:Spawn();
	  melon:Activate();
	  DoPropSpawnedEffect(melon);
	  return melon;
	  end
	end
end
duplicator.RegisterEntityClass("lap_regencore", RegenCoreDupe, "Pos", "Ang");

function LeaderDupe (ply, Pose, Ange)
	local melon = ents.Create("lap_leader");
	if (!melon:IsValid()) then return false end
	melon:SetPos(Pose);
	melon:SetAngles(Ange);
	local tab = {
		Team = ply:GetNetworkedInt("melonteam");
	}
	table.Merge(melon:GetTable(), tab);
	if InBaseRange(ply) then
	local cost = (50000*server_settings.Int( "WM_toolcost", 1))
    if NRGCheck(ply, cost) then
	  melon:Spawn();
	  melon:Activate();
	  DoPropSpawnedEffect(melon);
	  return melon;
	  end
	end
end
duplicator.RegisterEntityClass("lap_leader", LeaderDupe, "Pos", "Ang");

function BarracksDupe (ply, Pose, Ange, Grave, MelonGrave, FollowRangee)
	local melon = ents.Create("johnny_barracks");
	if (!melon:IsValid()) then return false end
	melon:SetPos(Pose);
	melon:SetAngles(Ange);
	local tab = {
		Team = ply:GetNetworkedInt("melonteam");
		Grav = Grave;
		MelonGrav = MelonGrave;
		FollowRange = FollowRangee;
	}
	if Grave then 
  Gra = 0
  else
  Gra = 1
  end
	if MelonGrave then 
  MGra = 0
  else
  MGra = 1
  end
	table.Merge(melon:GetTable(), tab);
	if InBaseRange(ply) then
	local cost = ((10000-MGra*4000-Gra*2000)*server_settings.Int( "WM_toolcost", 1))
    if NRGCheck(ply, cost) then
	  melon:Spawn();
	  melon:Activate();
	  DoPropSpawnedEffect(melon);
	  return melon;
	  end
	end
end
duplicator.RegisterEntityClass("johnny_barracks", BarracksDupe, "Pos", "Ang", "Grav", "MelonGrav", "FollowRange");

function HeavyBarracksDupe (ply, Pose, Ange, Grave, MelonGrave, FollowRangee)
	local melon = ents.Create("lap_heavybarracks");
	if (!melon:IsValid()) then return false end
	melon:SetPos(Pose);
	melon:SetAngles(Ange);
	local tab = {
		Team = ply:GetNetworkedInt("melonteam");
		Grav = Grave;
		MelonGrav = MelonGrave;
		FollowRange = FollowRangee;
	}
	if Grave then 
  Gra = 0
  else
  Gra = 1
  end
	if MelonGrave then 
  MGra = 0
  else
  MGra = 1
  end
	table.Merge(melon:GetTable(), tab);
	if InBaseRange(ply) then
	local cost = ((10000-MGra*4000-Gra*2000)*server_settings.Int( "WM_toolcost", 1))
    if NRGCheck(ply, cost) then
	  melon:Spawn();
	  melon:Activate();
	  DoPropSpawnedEffect(melon);
	  return melon;
	  end
	end
end
duplicator.RegisterEntityClass("lap_heavybarracks", HeavyBarracksDupe, "Pos", "Ang", "Grav", "MelonGrav", "FollowRange");

function MunitionsDupe (ply, Pose, Ange, Grave, MelonGrave, FollowRangee)
	local melon = ents.Create("lap_munitions");
	if (!melon:IsValid()) then return false end
	melon:SetPos(Pose);
	melon:SetAngles(Ange);
	local tab = {
		Team = ply:GetNetworkedInt("melonteam");
		Grav = Grave;
		MelonGrav = MelonGrave;
		FollowRange = FollowRangee;
	}
	if Grave then 
  Gra = 0
  else
  Gra = 1
  end
	if MelonGrave then 
  MGra = 0
  else
  MGra = 1
  end
	table.Merge(melon:GetTable(), tab);
	if InBaseRange(ply) then
	local cost = ((10000-MGra*4000-Gra*2000)*server_settings.Int( "WM_toolcost", 1))
    if NRGCheck(ply, cost) then
	  melon:Spawn();
	  melon:Activate();
	  DoPropSpawnedEffect(melon);
	  return melon;
	  end
	end
end
duplicator.RegisterEntityClass("lap_munitions", MunitionsDupe, "Pos", "Ang", "Grav", "MelonGrav", "FollowRange");

function BasePropDupe (ply, Pose, Masse, modele, Ange, Grave, MaxHealthe)
	local melon = ents.Create("melon_baseprop");
	if (!melon:IsValid()) then return false end
	melon:SetPos(Pose);
	melon:SetAngles(Ange);
	local tab = {
		mass = Masse;
		model = modele;
		Team = ply:GetNetworkedInt("melonteam");
		Grav = Grave
	}
	table.Merge(melon:GetTable(), tab);
  if Grave ~= nil && Grave == true then 
  MGra = 3
  else
  MGra = 1
  end
	table.Merge(melon:GetTable(), tab);
	if InBaseRange(ply) then
	   local cost = (Masse*server_settings.Int( "WM_healthtomass", 1.5)*server_settings.Int( "WM_propcost", 3)*MGra)
        if NRGCheck(ply, cost) then
	   melon:Spawn();
	   melon:Activate();
	    if Grav == true then
	    melon:GetPhysicsObject():EnableGravity(false)
	    end
        DoPropSpawnedEffect(melon);
        return melon;
        end
    end
end
duplicator.RegisterEntityClass("melon_baseprop", BasePropDupe, "Pos", "mass", "Model", "Ang", "Grav", "maxhealth");
